package com.qf.fmall.controller;

import com.qf.fmall.service.ProductService;
import com.qf.fmall.vo.ResultVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@Api(value = "商品展示页面", tags = "商品展示")
@RestController
@RequestMapping(value = "/product")
public class ProductController {

    @Autowired
    private ProductService productService;

    @ApiImplicitParam(dataType = "Integer", name = "productId", value = "商品ID", required = true)
    @CrossOrigin
    @RequestMapping(value = "/detail-info/{productId}", method = RequestMethod.GET)
    public ResultVo detailInfo(@PathVariable("productId") Integer productId) {
        return productService.detailInfo(productId);
    }

    @ApiImplicitParam(dataType = "Integer", name = "productId", value = "商品ID", required = true)
    @CrossOrigin
    @RequestMapping(value = "/detail-params/{productId}", method = RequestMethod.GET)
    public ResultVo detailParam(@PathVariable("productId") String productId) {
        return productService.detailParam(productId);
    }

    @ApiImplicitParams({@ApiImplicitParam(dataType = "Integer", name = "productId", value = "商品ID", required = true),
            @ApiImplicitParam(dataType = "Integer", name = "pageNum", value = "每页的第几页", required = true),
            @ApiImplicitParam(dataType = "Integer", name = "limit", value = "每页展示的数据数", required = true)
    })
    @CrossOrigin
    @RequestMapping(value = "/detail-commonts/{productId}", method = RequestMethod.GET)
    public ResultVo detailCommonts(@PathVariable("productId") Integer productId, Integer pageNum, Integer limit) {
        return productService.detailCommonts(productId, pageNum, limit);
    }
}
